﻿using Microsoft.Extensions.DependencyInjection;
using Mozhi.Abp.Domain.BasicData.Repositories;
using Mozhi.Abp.Domain.BasicData;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
using Mozhi.Abp.Domain.Repository.BasicData;
using Mozhi.Abp.Domain.AuthorCenter;
using Mozhi.Abp.Domain.Repository.BasicData.RemoteRepositories;
using Mozhi.Abp.Domain.AuthorCenter.Repository;
using Mozhi.Abp.Core.Networks;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
using mozhi.smarterp.Finance.Treasuries;
using Microsoft.EntityFrameworkCore;
using mozhi.smarterp.Finance.Supplychains.Purchase.Repositories;
using mozhi.smarterp.Finance.Supplychains.Purchase;

namespace mozhi.smarterp.Finance.EntityFrameworkCore;

[DependsOn(
    typeof(FinanceDomainModule),
    typeof(AbpEntityFrameworkCoreModule)
)]
public class FinanceEntityFrameworkCoreModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddAbpDbContext<FinanceDbContext>(options =>
        {
                /* Add custom repositories here. Example:
                 * options.AddRepository<Question, EfCoreQuestionRepository>();
                 */
        });

        Configure<AbpEntityOptions>(options =>
        {
            options.Entity<PaymentRequisition>(op =>
            {
                op.DefaultWithDetailsFunc = query => query.Include(o => o.Items);
            });
        });

        context.Services.AddScoped(typeof(IProductRepository), typeof(ProductRepository));
        context.Services.AddScoped(typeof(ISupplierRepository), typeof(SupplierRepository));
        context.Services.AddScoped(typeof(IUnitRepository), typeof(UnitRepository));
        context.Services.AddScoped(typeof(IEmployeeRepository), typeof(EmployeeRepository));
        context.Services.AddScoped(typeof(IProductAuxiliaryUnitRepository), typeof(ProductAuxiliaryUnitRepository));
        context.Services.AddScoped(typeof(IWarehouseRepository), typeof(WarehouseRepository));
        context.Services.AddScoped(typeof(IDepartmentRepository), typeof(DepartmentRepository));
        context.Services.AddScoped(typeof(INumberGeneratorRepository), typeof(NumberGeneratorRepository));
        context.Services.AddScoped(typeof(ICurrencyRepository), typeof(CurrencyRepository));
        context.Services.AddScoped(typeof(ITaxRateRepository), typeof(TaxRateRepository));
        context.Services.AddScoped(typeof(IOrganizationRepository), typeof(OrganizationRepository));
        context.Services.AddScoped(typeof(ICustomerRepository), typeof(CustomerRepository));
        context.Services.AddScoped(typeof(IPurchaseOrderRepository), typeof(PurchaseOrderRepository));
    }
}
